package com.woniuxy.handler;

import com.woniuxy.service.StatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.*;

/**
 * 〈一句话功能简述〉<br>
 * 〈统计类handler〉
 *
 * @author jia
 * @create 2019/9/28
 * @since 1.0.0
 */
@RequestMapping("/statistics")
@RestController
public class StatisticsHandler {

    @Autowired
    public StatisticsService statisticsService;

    //最近7天的流拍商品数
    @GetMapping("/auction")
    public List<Map> statisticsAuction() {
        Map<String, String> map = new HashMap<>();
        List<Map> mapList = new ArrayList<>();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date date = new Date();
        String d = sdf.format(date);
//        map.put("time", "2019-9-28");
//        map.put("count", "101");
//        mapList.add(map);
//        mapList.add(map);
//        Map<String, String> map1 = new HashMap<>();
//        map1.put("time", "2019-9-20");
//        map1.put("count", "202");
//        mapList.add(map1);
//        mapList.add(map1);
//        Map<String, String> map2 = new HashMap<>();
//        map2.put("time", "2019-9-23");
//        map2.put("count", "800");
//        mapList.add(map2);
//        mapList.add(map2);
//        mapList.add(map2);
        mapList = statisticsService.selectCountByDay(d);
        //System.out.println(mapList);
        return mapList;
    }

    @GetMapping("/online")
    public int statisticsAuctionOnline(){
        return statisticsService.findAuctionOnline()+1000;
    }
}
